package com.design_patterns.command;

/**
 * @author: 李德才
 * @description:
 * @create: 2020-09-19 17:22
 **/
public class DeleteCommand extends Command {
    Content content;
    String deleteString;

    public DeleteCommand(Content content) {
        this.content = content;
    }


    @Override
    public void doIt() {
        int index = content.stringList.size() - 1;
        deleteString = content.stringList.get(index);
        content.stringList.remove(index);
    }

    @Override
    public void undo() {
        content.stringList.add(deleteString);
    }
}
